home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 June
/
Macworld (1999-06).dmg
/
Shareware World
/
Info
/
For Developers
/
MacZoop2.0.sea
/
MacZoop2.0
/
Required Classes
/
ZApplication.h
< prev
next >
Wrap
Text File
|
1999-02-24
|
5KB
|
212 lines
/*************************************************************************************************
*
*
* MacZoop - "the framework for the rest of us"
*
*
*
* ZApplication.h -- the application object
*
*
*
*
*
* © 1996, Graham Cox
*
*
*
*
*************************************************************************************************/
#pragma once
#ifndef __ZAPPLICATION__
#define __ZAPPLICATION__
#ifndef __ZCOMMANDER__
#include "ZCommander.h"
#endif
class ZEventHandler;
class ZWindow;
class ZUndoTask;
class ZPrinter;
class ZMenuBar;
// for easier adoption of navigation services, the fileTypes handle now incorporates a
// header such that it mimics an 'open' resource.
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=mac68k
#endif
typedef struct
{
OSType appSignature;
short reserved;
short osTypeCount;
OSType osType[1];
}
FTypeList, *FTypeListPtr, **FTypeListHdl;
#if PRAGMA_ALIGN_SUPPORTED
#pragma options align=reset
#endif
// app class info:
DEFINECLASSID( ZApplication, 'zapp' );
// app class definition:
class ZApplication : public ZCommander
{
friend class ZEventHandler;
protected:
Boolean done; // normally FALSE, if set TRUE, will try to quit
short phase; // current phase
short appResRefNum; // refnum of application resource file
ZEventHandler* zEH; // event handler object
Handle shortageFund; // to deal with tight memory, we can release this
FTypeListHdl itsFileTypes; // list of filetypes we can open
ZUndoTask* curUndoTask; // current undoable task
ZPrinter* itsPrinter; // printer object for handling print commands
Boolean memIsShort; // flag memory problem
Boolean userHasSeenAlert; // TRUE if user has been warned about the memory
Boolean splashVisible; // TRUE if start-up splash is displayed
short msDepth; // screen depth of main screen
public:
ZApplication();
virtual ~ZApplication();
// initialisation and clean-up
virtual void InitMacZoop( const short numMasterBlocks = 8 );
virtual void StartUp() {};
virtual void ShutDown() {};
virtual void ReadPrefs() {};
virtual void ShowSplash() {};
virtual void RunFirstTask() {};
// event processing
virtual void Run();
virtual Boolean Quit();
virtual void RequestQuit();
virtual Boolean MemoryShortage( const Size bytesShort );
virtual void Process1Event();
virtual void Process1Event( EventRecord* anExternalEvent );
virtual void ProcessAllEvents();
virtual void HandleCommand( const long aCmd );
virtual void HandleCommand( const short menuID, const short itemID );
virtual void UpdateMenus();
virtual Boolean GetCurrentEvent( EventRecord* anEvent );
virtual void HandleAppleEvent( AEEventClass aeClass, AEEventID aeID,
AppleEvent* aeEvt, AppleEvent* reply );
virtual void MouseNotInAnyWindow( const Point globalMouse );
virtual void HandleMBarHiding( const Point globalPt );
virtual void WaitApplicationForeground();
virtual void ProcessHLEvent( const EventRecord& theEvent ) {};
// status utilities
virtual short GetClicks();
virtual Boolean InBackground();
virtual void GetName( Str255 appName );
virtual void DoSuspend();
virtual void DoResume();
// error processing
virtual void HandleError( OSErr theErr );
// window construction
virtual ZWindow* OpenNewWindowType( OSType aType = 0 );
virtual void CloseAll( Boolean closeFloaters = FALSE );
virtual ZWindow* GetFrontWindow();
virtual void AboutBox();
virtual void DoPreferences() {};
// opening files
virtual Boolean PickFile( FSSpec* aFile, OSType* fType );
virtual ZWindow* OpenFile( const FSSpec& aFile, const OSType fType, Boolean isStationery = FALSE );
// extending the file types
virtual void AddFileType( const OSType aType );
virtual Boolean CanOpenFileType( const OSType aType );
// undo task handling
virtual void SetTask( ZUndoTask* aTask );
virtual void UpdateUndo();
inline ZUndoTask* GetUndoTask() { return curUndoTask; };
// printer handling
virtual void MakePrinter();
virtual void DoPageSetup();
virtual void DoPrint();
inline ZPrinter* GetPrinter() { return itsPrinter; };
// other inline accessors
inline short GetPhase() { return phase;};
inline FTypeListHdl GetFileTypeList() { return itsFileTypes; };
inline Boolean MemoryCrisis() { return memIsShort; };
inline Boolean UserHasSeenMemoryCrisisAlert() { return userHasSeenAlert; };
inline ZEventHandler* GetEventHandler() { return zEH; };
inline short GetAppRefnum() { return appResRefNum; };
protected:
void InitMacApplication( const short numMasterBlocks );
virtual void MakeHelpers();
virtual void MakeClipboard();
virtual Boolean CheckCanRun();
virtual void InitMenuBar();
virtual void CheckLowMemory();
virtual void RegisterClasses();
virtual ZWindow* MakeNewWindowType( OSType aType = 0 );
};
// possible values of "phase"
enum
{
kInitialising,
kRunning,
kQuitting,
msgApplicationSuspending = 'susp',
msgApplicationResuming = 'rsum',
msgMainScreenDepthChanged = 'msdx'
};
enum
{
kDefaultWindowType = 0
};
#define kUndoStrIndex 5
#define kRedoStrIndex 6
#define kCantUndoStrIndex 7
#define kCantRunAlertID 131
#define kFatalStartupErrAlertID 136
#define kModalDialogOnScreenErr 137
#define kAEReopenApplication 'rapp' // new MacOS 8 apple event
#endif